package com.todo.sight.application.frontend.controller;

import com.todo.common.common.entity.response.BizPageResponse;
import com.todo.common.common.entity.response.BizResponse;
import com.todo.sight.application.frontend.service.SightPortalAggService;
import com.todo.sight.application.iface.frontend.SightPortalIface;
import com.todo.sight.application.iface.frontend.request.RecommendSightParam;
import com.todo.sight.application.iface.frontend.request.SearchSightPoiParam;
import com.todo.sight.application.iface.frontend.request.SearchSightSummaryParam;
import com.todo.sight.application.iface.frontend.response.SightInfoVO;
import com.todo.sight.application.iface.frontend.response.SightSummaryVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author azhebuxing
 * @date 2024/5/14 13:42
 * @description
 */
@Slf4j
@RestController
@RequestMapping("/portal/sight")
@Tag(name = "景点门户信息前台接口", description = "景点门户信息前台接口")
public class SightPortalController implements SightPortalIface {

    @Resource
    private SightPortalAggService sightPortalAggService;


    @Override
    @Operation(summary = "根据关键词搜索景点列表")
    @PostMapping("/searchSight")
    public BizPageResponse<SightInfoVO> searchSightPOI(@RequestBody SearchSightPoiParam param) {
        if (param == null) {
            return BizPageResponse.success();
        }
        if (!param.baseCheck()) {
            log.warn("SightPortalController#searchSight 根据关键词搜索景点Poi列表失败，keyword信息为空，默认返回成功不做展示 ");
            return BizPageResponse.success();
        }
        return sightPortalAggService.searchSightPOI(param);
    }

    @Override
    public BizPageResponse<SightSummaryVO> searchSightSummary(@RequestBody SearchSightSummaryParam param) {
        if (param == null) {
            return BizPageResponse.success();
        }
        if (!param.baseCheck()) {
            log.warn("SightPortalController#searchSightSummary 根据关键词搜索景点列表失败，keyword信息为空，默认返回成功不做展示 ");
            return BizPageResponse.success();
        }
        return sightPortalAggService.searchSightSummary(param);
    }

    @Override
    @Operation(summary = "根据城市获取热门景点列表(人工配置，默认一个城市最多20个数据，且热点城市存在)")
    @PostMapping("/hotSightListByCity")
    public BizResponse<List<SightSummaryVO>> hotSightListByCity(@RequestBody RecommendSightParam param) {
        if (param == null) {
            return BizResponse.success();
        }
        if (!param.baseCheck()) {
            log.warn("SightPortalController#hotSightListByCity 根据城市获取热门景点列表查询失败，城市信息为空，默认返回成功不做展示 ");
            return BizResponse.success();
        }
        return sightPortalAggService.hotSightListByCity(param);
    }
}
